using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using sdm.exam.domain;
using sdm.exam.domain.Abstract;
using sdm.exam.domain.DataContext;
using sdm.exam.domain.Entities;

namespace sdm.exam.test.Domain
{
    [TestClass]
    public class EducationDomainTest
    {
        private EducationDomain _domain = null;

        /// <summary>
        /// Initialize the test.
        /// </summary>
        [TestInitialize]
        public void Start()
        {
            Ninjector.Kernel.Bind<ISdmExamRepository>().ToConstant(new DataContext(ConnectionStrings.TestConnection));
            _domain = new EducationDomain();
        }

        /// <summary>
        /// Cleanup the test.
        /// </summary>
        [TestCleanup]
        public void End()
        {
            Ninjector.Kernel.Unbind<ISdmExamRepository>();
        }

        /// <summary>
        /// Tests whether or not we gets a list of educations
        /// </summary>
        [TestMethod]
        public void GetListOfEducationsTest()
        {
            //Ninjector.Kernel.Bind<ISdmExamRepository>().ToConstant(new DataContext(ConnectionStrings.TestConnection));
            //var domain = new EducationDomain();

            List<domain.Entities.Education> educationList = _domain.GetListOfEducations();

            Assert.IsNotNull(educationList);
        }

        /// <summary>
        /// Tests whether or not, we get a specific id according to a specific id.
        /// </summary>
        [TestMethod]
        public void GetEducationByIdTest()
        {
            //Ninjector.Kernel.Bind<ISdmExamRepository>().ToConstant(new DataContext(ConnectionStrings.TestConnection));
            //var domain = new EducationDomain();

            const int id = 36;
            Education edu = _domain.GetEducationById(id);
            Assert.AreEqual(id,edu.Id);
        }

        /// <summary>
        /// Tests whether or not an education is added.
        /// </summary>
        [TestMethod]
        public void AddEducationTest()
        {
            const string name = "Computer science";

            bool sucess = _domain.AddEducation(name);

            Assert.IsTrue(sucess);
        }
    }
}